package com.goods.controller.business;


import com.goods.business.service.InStockService;
import com.goods.business.service.SupplierService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockDetailVO;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.SupplierVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(tags = "业务管理-入库记录")
@RestController
@RequestMapping("/business/inStock")
public class InStockController {
    @Autowired
    private InStockService inStockService;


    @ApiOperation("分页查询入库记录")
    @GetMapping("/findInStockList")
    public ResponseBean findInStockList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                        @RequestParam(value = "pageSize", defaultValue = "7") Integer pageSize,
                                        InStockVO inStockVO){
        PageVO<InStockVO> inStockVOPageVO = inStockService.findInStockList(pageNum,pageSize,inStockVO);
        return ResponseBean.success(inStockVOPageVO);
    }
    @ApiOperation("放入回收站")
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        return ResponseBean.success(inStockService.remove(id));
    }
    @ApiOperation("回收站放回")
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        return ResponseBean.success(inStockService.back(id));
    }
    @ApiOperation("回收站删除")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        return ResponseBean.success(inStockService.delete(id));
    }
    @ApiOperation("详情明细")
    @GetMapping("/detail/{id}")
    public ResponseBean detail(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                               @RequestParam(value = "pageSize", defaultValue = "7") Integer pageSize,
                               @PathVariable Long id,InStockDetailVO inStockDetailVO){
        InStockDetailVO inStockVOPageVO = inStockService.detail(id,pageNum,pageSize,inStockDetailVO);
        return ResponseBean.success(inStockVOPageVO);
    }
    @ApiOperation("物资入库")
    @PostMapping("/addIntoStock")
    public ResponseBean addIntoStock(@RequestBody InStockVO inStockVO){
        return ResponseBean.success(inStockService.addIntoStock(inStockVO));
    }
    @ApiOperation("审批通过")
    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        return ResponseBean.success(inStockService.publish(id));
    }

}
